<template>
  <view class="content">
    <!-- 积分用途 -->
    <view class="xiaofei">
      <view class="purpose" v-for="(item, index) in data.list" :key="index">
        <view class="purpose_item">
          <view class="purpose_text">{{ item.remark }}</view>
          <view class="purpose_text">会员id：{{ item.memberBO.mchMemberNo }}</view>
          <view class="purpose_time">{{ item.modifiedDate }}</view>
        </view>
        <view class="purpose_monty">
          {{ item.changeAmount }}
        </view>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { err, toast, to } from '@/utils/uniapi';
import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { api } from '@/api/mop_api';
const data = reactive({
  list: [] as any[],
  page: 1,
  size: 20,
  pageTotal: 0
});
onLoad(() => {
  points();
});
async function points() {
  const { page, size } = data;
  try {
    const res = await api.moppoints({ page, size });
    if (res.respCode === 200) {
      const list = JSON.parse(res.source);
	  console.log(list)
      data.pageTotal = res.pageTotal;
      data.list = data.list.length === 0 ? list : data.list.concat(list);
    }
  } catch (error) {
    err(error);
    throw error;
  }
}
onReachBottom(() => {
  const { list, pageTotal, page } = data;
  if (list.length < pageTotal) {
    (data.page = page + 1), points();
  } else {
    toast('已加载全部数据');
  }
});
</script>

<style scoped>
.detailed {
  width: 707rpx;
  height: 154rpx;
  background-size: 100% 100%;
  margin: 20rpx auto;
  overflow: hidden;
  background-color: #ffffff;
  font-size: 36rpx;
  font-family: Source Han Sans CN;
  font-weight: bold;
  line-height: 154rpx;
  padding-left: 20rpx;
  box-sizing: border-box;
  border-radius: 24rpx;
}
.xiaofei {
  width: 100%;
  padding-top: 15rpx;
}

.purpose {
  width: 700rpx;
  /* height: 100rpx; */
  margin: 8rpx auto;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  overflow: hidden;
  background-color: #ffffff;
  border-radius: 24rpx;
}

.purpose_item {
  width: 500rpx;
  float: left;
  margin-left: 30rpx;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.purpose_text {
  font-size: 28rpx;
  font-family: Source Han Sans CN;
  font-weight: 500;
  margin: 14rpx 0;
}

.purpose_time {
  font-size: 24rpx;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: #7e6d61;
}

.purpose_monty {
  width: 130rpx;
  float: right;
  font-size: 30rpx;
  font-family: Source Han Sans CN;
  font-weight: 500;
  line-height: 100rpx;
  margin-right: 40rpx;
}
</style>
